﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Shared;

namespace DAL
{
    public class ProductRepository:BaseRepository<Product>, IProductRepository
    {
        public ProductRepository(IdbContext context):base(context)
        { }

        public ICollection<Product> GetProductByCategory(string catName)
        {
            List<Product> prodList = new List<Product>();
            foreach (var item in _context.Set<Product>())
            {
                if (item.Category == catName)
                    prodList.Add(item);
            }
            return prodList;
        }

        public Product GetProductByProductId(int productId)
        {            
            return _context.Set<Product>().FirstOrDefault((n) => n.ProductId == productId);
            
        }
    }
}
